package com.nashuju.web.controller.sw;

import org.durcframework.core.DefaultMessageResult;
import org.durcframework.core.GridResult;
import org.durcframework.core.MessageResult;
import org.durcframework.core.controller.CrudController;
import com.nashuju.web.entity.sw.STask;
import com.nashuju.web.entity.sw.STaskSch;
import com.nashuju.web.service.sw.STaskService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class STaskController extends
		CrudController<STask, STaskService> {

		//新增记录
	@RequestMapping("/addSTask.do")
	public @ResponseBody
	MessageResult addSTask(STask entity) {
		MessageResult messageResult = this.save(entity);
		if(this.getService().createSTaskSchedule(entity))
		{
			messageResult.setMessage("创建任务列表和待发布列表成功！");
			return messageResult;
		}
		return messageResult;
		
	}

	//删除记录
	@RequestMapping("/delSTask.do")
	public @ResponseBody
	MessageResult delSTask(STask entity) {
		MessageResult messageResult = new DefaultMessageResult();
		if(this.getService().delSTaskSchedule(entity))
		{
			messageResult.setMessage("删除任务列表和待发布列表成功！");
			return messageResult;
		};
		return this.delete(entity);
	}
	
	//修改记录
	@RequestMapping("/updateSTask.do")
	public @ResponseBody
	MessageResult updateSTask(STask entity) {
		return this.update(entity);
	}

	//条件查询分页操作
	@RequestMapping("/listSTask.do")
	public @ResponseBody
	GridResult listSTask(STaskSch searchEntitySch) {
		return this.query(searchEntitySch);
	}

	
	//条件查询并返回所有记录
	@RequestMapping("/listAllSTask.do")
    public @ResponseBody Object listAllSTask(STaskSch searchEntitySch) {
        return this.queryAll(searchEntitySch);
    }

    //获取详细信息
	@RequestMapping("/getSTaskById.do")
    public @ResponseBody STask getSTaskById(STask entity) {
        return this.getService().get(entity.getId());
    }

 	

}